<template>
    <uxt-page :title="title">
        <uxt-bar-group title="设置">
            <uxt-single-selector-bar
                title="大小"
                desc="size"
                :options="sizes"
                v-model="size"
            ></uxt-single-selector-bar>
            <uxt-bar title="圆角" desc="radius | round">
                <template slot="right">
                    <uxt-radio-group v-model="radius" size="sm" type="btn">
                        <uxt-radio label="无" value=""></uxt-radio>
                        <uxt-radio classes="margin-lr-sm" label="小圆角" value="radius"></uxt-radio>
                        <uxt-radio label="大圆角" value="round"></uxt-radio>
                    </uxt-radio-group>
                </template>
            </uxt-bar>
            <uxt-color-selector-bar
                title="前景色"
                desc="color=xx/颜色值"
                v-model="color"
            ></uxt-color-selector-bar>
            <uxt-color-selector-bar
                title="背景色"
                desc="bg-color=xx/颜色值"
                v-model="bgColor"
                light
                gradual
            ></uxt-color-selector-bar>
            <uxt-bar title="文字">
                <template slot="right">
                    <uxt-input
                        classes="solid radius margin-xs"
                        :styles="{ width: '100rpx' }"
                        v-model="text"
                    ></uxt-input>
                </template>
            </uxt-bar>
            <uxt-bar title="图标">
                <template slot="right">
                    <uxt-input
                        classes="solid radius margin-xs"
                        :styles="{ width: '100rpx' }"
                        v-model="icon"
                    ></uxt-input>
                </template>
            </uxt-bar>
            <uxt-bar title="头像" desc="avatar">
                <template slot="right">
                    <uxt-switch v-model="avatar" radius size="sm"></uxt-switch>
                </template>
            </uxt-bar>
        </uxt-bar-group>
        <uxt-bar-group title="事件">
            <template slot="right">
                <text @click="events = ''">清空</text>
            </template>
            <view
                class="padding bg-white"
                v-html="events"
                style="height: 200rpx; overflow-y: auto;"
            ></view>
        </uxt-bar-group>
        <uxt-bar-group title="展示">
            <view class="padding bg-white text-center">
                <uxt-avatar
                    :avatar="
                        avatar
                            ? 'https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg'
                            : ''
                    "
                    :size="sizes[size].value"
                    :round="radius === 'round'"
                    :radius="radius === 'radius'"
                    :color="color"
                    :bg-color="bgColor"
                    @click="handleEvent('click', $event)"
                >
                    <block v-if="icon"><uxt-icon :type="icon"></uxt-icon></block>
                    <block v-else>{{ text }}</block>
                </uxt-avatar>
            </view>
        </uxt-bar-group>
        <uxt-bar-group title="头像组">
            <view class="padding bg-white text-center">
                <uxt-avatar-group :size="sizes[size].value">
                    <uxt-avatar
                        v-for="i in 4"
                        :key="i"
                        :avatar="
                            avatar
                                ? 'https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg'
                                : ''
                        "
                        :size="sizes[size].value"
                        :round="radius === 'round'"
                        :radius="radius === 'radius'"
                        :color="color"
                        :bg-color="bgColor"
                        @click="handleEvent('click', $event)"
                    >
                        <block v-if="icon"><uxt-icon :type="icon"></uxt-icon></block>
                        <block v-else>{{ text }}</block>
                    </uxt-avatar>
                </uxt-avatar-group>
            </view>
        </uxt-bar-group>
    </uxt-page>
</template>

<script>
import uxtBarGroup from '@xtcoder/uxt/components/uxt-bar-group.vue'
import uxtBar from '@xtcoder/uxt/components/uxt-bar.vue'
import uxtRadioGroup from '@xtcoder/uxt/components/uxt-radio-group.vue'
import uxtRadio from '@xtcoder/uxt/components/uxt-radio.vue'
import uxtSwitch from '@xtcoder/uxt/components/uxt-switch.vue'
import uxtInput from '@xtcoder/uxt/components/uxt-input.vue'
import uxtSingleSelectorBar from '@xtcoder/uxt/components/uxt-single-selector-bar.vue'
import uxtColorSelectorBar from '@xtcoder/uxt/components/uxt-color-selector-bar.vue'
import uxtAvatar from '@xtcoder/uxt/components/uxt-avatar.vue'
import uxtIcon from '@xtcoder/uxt/components/uxt-icon.vue'
import uxtAvatarGroup from '@xtcoder/uxt/components/uxt-avatar-group.vue'

export default {
    components: {
        uxtBarGroup,
        uxtBar,
        uxtRadioGroup,
        uxtRadio,
        uxtSwitch,
        uxtInput,
        uxtSingleSelectorBar,
        uxtColorSelectorBar,
        uxtAvatar,
        uxtIcon,
        uxtAvatarGroup
    },
    data() {
        return {
            title: '头像',
            sizes: [
                {
                    label: 'sm-小',
                    value: 'sm'
                },
                {
                    label: 'df-默认',
                    value: 'df'
                },
                {
                    label: 'lg-大',
                    value: 'lg'
                },
                {
                    label: 'xl-超大',
                    value: 'xl'
                }
            ],
            size: 1,
            radius: '',
            text: 'A',
            icon: '',
            avatar: false,
            color: '',
            bgColor: 'theme',
            events: ''
        }
    },
    methods: {
        handleEvent(type, e) {
            this.events += `@${type}${e !== undefined ? `(${JSON.stringify(e)})` : ''}<br />`
        }
    }
}
</script>

<style lang="scss" scoped></style>
